package com.certification.servlet.capitulo10;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

public class MyIteratorTagClassic extends TagSupport {

	private static final long serialVersionUID = 1L;

	String[] movies = {"O senhor do seu anel","As transas do rei careca",
	"cidade das budegass"};
	int movieCounter;

	@Override
	public int doStartTag() {
		movieCounter = 0;
		
		return EVAL_BODY_INCLUDE;
	}

	@Override
	public int doAfterBody() throws JspException {
		if(movieCounter < movies.length){
			pageContext.setAttribute("movie", movies[movieCounter]);
			movieCounter++;
			return EVAL_BODY_AGAIN;
		}else{
			return SKIP_BODY;
		}

	}

	@Override
	public int doEndTag() throws JspException {
		return EVAL_PAGE;
	}

}
